﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Exam0312_WebForm
{
    public partial class Login : System.Web.UI.Page
    {
        //这是模拟的用户名和密码列表。key是用户名，value是密码
        public Dictionary<string,string> UserList=new Dictionary<string, string>()
        {
            {"zhangsan","123456" },
            {"lisi","123456" }
        };
        protected void Page_Load(object sender, EventArgs e)
        {
            //TODO:模拟登陆校验，用户名和密码列表

            //TODO：登录成功后，跳转到Default.aspx

            //TODO:登录失败，返回登录页并输出用户名或密码错误提示
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string ID = txtID.Text;
            string PWD = txtpwd.Text;
            foreach (KeyValuePair<string, string> item in UserList)
            {
                if (item.Key == ID && item.Value == PWD)
                {
                    Session["ID"] = ID;
                    Response.Redirect("Default.aspx");

                }
                else {

                    Response.Write("登入失败！");
                }
            }


        }
    }
}